// 防抖
function debounce<T extends (...args: any[]) => any>(
  func: T,
  delay: number,
): (...args: Parameters<T>) => void {
  let inDebounce: ReturnType<typeof setTimeout>

  return function (...args: Parameters<T>) {
    clearTimeout(inDebounce)
    inDebounce = setTimeout(() => func(...args), delay)
  }
}
export default debounce
